A program is mainly organised in two segments, the text segment and the data segment.
The text segment is where the compiled code of the program resides. The data segment is the place where global variables are stored. Dynamic memory allocation reserves the memory in this segment as well. 
Memory can be allocated dynamically on programmer's request by using the API function  "allouer". It does not clear the memory but allocates size bytes and returns a pointer to the allocated memory. The API function "liberer" is the equivalent of free.

We know that the "hardware" has 8 MB of RAM mapped at the address 0x8000\_0000. This module will then have 8 MB minus the size of the text segment available for allocation. Knowing where the data segment starts and ends (and its length), we manage it using a list of free blocks in the data segment. Initially, there will therefore be only one big block (having the size of the data segment) since it is empty.
 
This module defines the following functions:
\begin{itemize}
	\item void* malloc(size):

Allocates \textit{size} contiguous bytes in the data segment and returns a pointer to the first one. It also include an header to the reserved area to make operations like free possible. It returns NULL if the system is out of memory and the allocation could not be done. The allocation is done by going through the list of free blocks. When a block big enough is found, the memory is allocated and any remaining memory is added to the list as a new block (while the old one is deleted).

	\item int free(pointer):

Frees the memory dynamically allocated using malloc and pointed to by \textit{pointer}. It returns a code indicating whether the operation was sucessful or not. The most simple implementation of free could be putting the block having been deallocated at the beginning of the list.

\end{itemize}
